var isGlobal = true
var listener = function( e ) {
    //log: didShow received! userInfo: {"data":"test"}
    console.log( "CONNECTIVITY_CHANGE: " + JSON.stringify(e)  );
    document.getElementById("writeAppEventInfo").innerHTML = "收到监听:"+JSON.stringify(e);
}

function RegisterWatcher() {
    window.broadcaster.addEventListener('CONNECTIVITY', isGlobal, listener);
    document.getElementById("registerWatcherInfo").innerHTML = "注册成功";
}

function WriteAppEvent( ) {
    window.broadcaster.fireNativeEvent("CONNECTIVITY", isGlobal, "chenlh", function() {
        console.log( "event success!" );
    },function(){
        console.log( "event failed!" );
    });
}

function UnRegisterWatcher() {
    window.broadcaster.removeEventListener('CONNECTIVITY', listener);
    document.getElementById("unRegisterWatcherInfo").innerHTML = "取消成功";
}